% rhs和chs为全息图裁剪区域,zs为衍射距离
function reSfft(I0,rhs,chs,zs,lamda)


I0 = double(I0);
I0 = I0(1:rhs,1:chs);
[r,c] = size(I0);

k = 2*pi/lamda;%mm
sph = 3.18e-4;%全息图像素间距

Lox = sph*c;
Loy = sph*r;

xo=linspace(-Lox/2,Lox/2,c);
yo=linspace(-Loy/2,Loy/2,r);
[xo,yo]=meshgrid(xo,yo);

zi = zs;
Lix = c*lamda*zi/Lox;
Liy = r*lamda*zi/Loy;

x=linspace(-Lix/2,Lix/2,c);y=linspace(-Liy/2,Liy/2,r);
[x,y]=meshgrid(x,y);
F0=exp(1j*k* zi)/(1j*lamda*zi)*exp(1j*k/2/zi*(x.^2+y.^2));
F=exp(1j*k/2/zi.*(xo.^2+yo.^2));

holo = Loy/r*Lox/c*fftshift(fft2(I0.*F.*1));
holo = holo.*F0;
Ii = holo.*conj(holo);

I2 = log(Ii+1);
figure,imshow(I2,[]);
colormap(pink);
% title('S-FFT再现像');

% %位相分布
% ImO = imag( holo );%取
% ReO = real( holo );
% ph = atan(ImO ./ ReO );
% figure,imshow(ph,[]);


end

